home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / 3d_lib.zip / SCALE.C < prev    next >
C/C++ Source or Header  |  1993-05-09  |  1KB  |  48 lines

  1. /* Add scaling to transformation matrix
  2.  
  3.    Copyright (c) 1988 by Gus O'Donnell
  4.  
  5.    Revision history:
  6.  
  7.    Version 1.00         February 29, 1988       As released.
  8.  
  9.    Version 1.01         March 20, 1988          Created libraries for all
  10.                                                 memory models
  11.  
  12. */
  13. #include "3d.h"
  14. #include <float.h>
  15. #include <math.h>
  16. #include <stdio.h>
  17.  
  18. void    scale (double sx, double sy, double sz, MATRIX this_mat)
  19.  
  20. /* Add scaling to the transformation matrix.
  21.  
  22. Each coordinate may be scaled independently.  The result of the transformation
  23. is
  24.  
  25.                [x y z] -> [(sx * x) (sy * y) (sz * z)]
  26.  
  27. The matrix created for the scaling transformation is
  28.  
  29.            |  sx   0.0  0.0  0.0  |
  30.            |  0.0  sy   0.0  0.0  |
  31.            |  0.0  0.0  sz   0.0  |
  32.            |  0.0  0.0  0.0  1.0  |
  33.  
  34. The current transformation matrix this_mat is then multiplied by the scaling
  35. transformation matrix, thus concatenating the scaling operation with the
  36. current transformation.
  37. */
  38.  
  39. {
  40.     MATRIX s_mat;
  41.  
  42.     identity (s_mat);
  43.     s_mat [0] [0] = sx;
  44.     s_mat [1] [1] = sy;
  45.     s_mat [2] [2] = sz;
  46.     mat_mul (this_mat,s_mat,this_mat);
  47. }
  48.